<template>
  <div>
    <el-row style="margin-bottom: 20px">
      <el-button type="primary"  @click="dialogFormVisible2 = true">上/下机</el-button>
      <el-button type="primary"  @click="dialogFormVisible3 = true">考勤情况</el-button>
    </el-row>
    <el-row>
      <el-col>
        <el-table
          :data="tableData"
          style="width: 100%"
          border>
          <el-table-column
            prop="date"
            align="center"
            label="日期">
          </el-table-column>
          <el-table-column
            prop="name"
            align="center"
            label="课程名称">
          </el-table-column>
          <el-table-column
            prop="province"
            align="center"
            label="所在实训室">
          </el-table-column>
          <el-table-column
            prop="city"
            align="center"
            label="面向专业">
          </el-table-column>
          <el-table-column
            prop="address"
            align="center"
            label="班级">
          </el-table-column>
          <el-table-column
            prop="zip"
            align="center"
            label="实训手册">
          </el-table-column>
          <el-table-column
            align="center"
            label="操作">
            <template slot-scope="scope">
              <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
              <el-button @click="dialogFormVisible1 = true" type="text" size="small">评价</el-button>
              <el-button @click="handleClick(scope.row)" type="text" size="small">下载手册</el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          background
          style="margin-top: 10px;text-align: right"
          layout="prev, pager, next"
          :total="1000">
        </el-pagination>
      </el-col>
    </el-row>
    <el-dialog title="新增课程" :visible.sync="dialogFormVisible" width="40%">
      <el-form :model="form">
        <el-form-item label="课程名称" :label-width="formLabelWidth">
          <el-input v-model="form.name" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="日期" :label-width="formLabelWidth">
          <el-col>
            <el-date-picker type="date" placeholder="选择日期" v-model="form.date1" style="width: 100%;"></el-date-picker>
          </el-col>
        </el-form-item>
        <el-form-item label="所在实训室" :label-width="formLabelWidth">
          <el-input v-model="form.name" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="面向专业" :label-width="formLabelWidth">
          <el-select v-model="form.region" placeholder="请选择专业" style="width: 100%">
            <el-option label="专业一" value="shanghai"></el-option>
            <el-option label="专业二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="班级" :label-width="formLabelWidth" >
          <el-select v-model="form.region" placeholder="请选择班级" style="width: 100%">
            <el-option label="班级一" value="shanghai"></el-option>
            <el-option label="班级二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="实训手册" :label-width="formLabelWidth">
          <el-upload
            class="upload-demo"
            drag
            action="https://jsonplaceholder.typicode.com/posts/"
            multiple>
            <i class="el-icon-upload"></i>
            <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
            <!--<div class="el-upload__tip" slot="tip">只能上传jpg/png文件，且不超过500kb</div>-->
          </el-upload>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>
      </div>
    </el-dialog>
    <el-dialog title="课程评价" :visible.sync="dialogFormVisible1" width="40%">
      <el-form :model="form">
        <el-form-item label="课程安排" :label-width="formLabelWidth">
          <el-input v-model="form.name" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="实训环境" :label-width="formLabelWidth">
          <el-input v-model="form.name" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="实训设备" :label-width="formLabelWidth">
          <el-input v-model="form.name" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="老师评价" :label-width="formLabelWidth">
          <el-input v-model="form.name" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>
      </div>
    </el-dialog>
    <el-dialog title="扫码" :visible.sync="dialogFormVisible2" width="40%">
      <img src="../../assets/img/timg.jpg" alt="" width="200px">
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible2 = false">取 消</el-button>
        <el-button type="primary" @click="dialogFormVisible2 = false">确 定</el-button>
      </div>
    </el-dialog>
    <el-dialog title="出勤情况" :visible.sync="dialogFormVisible3" width="80%">
      <el-row>
        <el-col>
          <el-calendar>
            <!-- 这里使用的是 2.5 slot 语法，对于新项目请使用 2.6 slot 语法-->
            <template
              slot="dateCell"
              slot-scope="{date, data}">
              <p class=''>
                {{ data.day.split('-').slice(1).join('-') }} {{ '✔️'}}<br /> {{dealMyDate(data.day)}}
              </p>
            </template>
          </el-calendar>
        </el-col>
      </el-row>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible3 = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  export default {
    name: "stadEval",
    data() {
      return {
        dialogFormVisible1: false,
        dialogFormVisible2: false,
        dialogFormVisible3: false,
        tableData: [{
          date: '2016-05-02',
          name: '王小虎',
          province: '陕西',
          city: '计算机科学与应用',
          address: '陕西省西安市',
          zip: 200333
        }, {
          date: '2016-05-04',
          name: '王小虎',
          province: '陕西',
          city: '计算机科学与应用',
          address: '陕西省西安市',
          zip: 200333
        }, {
          date: '2016-05-01',
          name: '王小虎',
          province: '陕西',
          city: '计算机科学与应用',
          address: '陕西省西安市',
          zip: 200333
        }, {
          date: '2016-05-03',
          name: '王小虎',
          province: '陕西',
          city: '计算机科学与应用',
          address: '陕西省西安市',
          zip: 200333
        }],
        dialogFormVisible: false,
        form: {
          name: '',
          region: '',
          date1: '',
          date2: '',
          delivery: false,
          type: [],
          resource: '',
          desc: ''
        },
        formLabelWidth: '120px',
        resDate: [
          {"date":"2020-08-20","content":"早退"},
          {"date":"2020-08-26","content":"早退"},
          {"date":"2020-08-26","content":"早退"}
        ]
      }
    },
    methods: {
      handleClick(row) {
        console.log(row);
        this.dialogFormVisible = true
      },
      dealMyDate(v) {
        console.log(v)
        let len = this.resDate.length
        let res = ""
        for(let i=0; i<len; i++){
          if(this.resDate[i].date == v) {
            res = this.resDate[i].content
            break
          }
        }
        return res
      }
    },
  }
</script>

<style scoped lang="scss">
/deep/.el-dialog__body{
  text-align: center;
}
</style>
